<extend name='Public/demo' />

<block name="contents">
    <div class="row">
        <div class="col-lg-12">
            <section class="panel">
                <link href="__PUBLIC__/fileInput/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
                <script src="__PUBLIC__/fileInput/js/fileinput.js" type="text/javascript"></script>
                <script src="__PUBLIC__/fileInput/js/locales/zh.js" type="text/javascript"></script>
                <div class="htmleaf-container">
                <div class="container kv-main">
                    <form enctype="multipart/form-data">
                        <div class="form-group">
                            <input id="file-5" class="file" type="file" multiple data-preview-file-type="any" data-upload-url="{:U('Vip/ajaxbanner')}" data-preview-file-icon="">
                        </div>
                    </form>
                </div>
            </div>
            </section>
        </div>
    </div>

    <!-- banner展示 S -->

    <div class="row">
          <div class="col-lg-12">
              <section class="panel">
                  <header class="panel-heading">
                      Banner
                  </header>
                  <table class="table table-striped table-advance table-hover">
                      <thead>
                      <tr>
                          <th><i class="icon-bullhorn"></i> Banner预览</th>
                          <th class="hidden-phone"><i class="icon-question-sign"></i> 添加时间</th>
                          <th><i class=" icon-edit"></i> 是否可见</th>
                          <th>操作</th>
                      </tr>
                      </thead>
                      <tbody>
                      <?php foreach($res as $key => $val){ ?>
                      <tr>
                          <td><img src="__PUBLIC__<?php echo $val['banner_path'] ?>" style="width:300px"></td>
                          <td class="hidden-phone"><?php echo date('Y-m-d H:i:s',$val['time']) ?></td>
                          <td>
                              <div class="switch switch-square showbanner" data="<?php echo $val['banner_id'] ?>" data-on-label="<i class=' icon-ok'></i>" data-off-label="<i class='icon-remove'></i>">
                                  <input type="checkbox"  <?php echo $val['status'] == '0' ? 'checked' : '' ; ?> />
                              </div>
                          </td>
                          <td>
                              <button class="btn btn-danger btn-xs delbanner" data="<?php echo $val['banner_id'] ?>"><i class="icon-trash "></i> 删除</button>
                          </td>
                      </tr>
                      <?php } ?>
                      </tbody>
                  </table>
              </section>
          </div>
      </div>
      <script src="__PUBLIC__/Theme/js/bootstrap-switch.js"></script>
    <!-- banner展示 E -->
        <script type="text/javascript">
            //删除banner
            $('.delbanner').click(function(){
                //得到当前元素的元素对象
                var th = $(this);
                //得到要删除的banner的ID
                var id = $(this).attr('data');
                // console.log(id);
                //发送ajax
                $.post("{:U('Vip/delbanner')}",{id:id},function(data){
                    if (data == 'yes') {
                        th.parents('tr').remove();
                    }
                });
            })

            //设置是否可见
            $('.showbanner').click(function(){
                //得到要显隐的banner的ID
                var id = $(this).attr('data');
                //得到当前的元素
                var th = $(this);
                //发送ajax
                $.post("{:U('Vip/ajaxstatus')}",{id:id},function(data){});
            })
        </script>
</block>
